import time

def bubble_sort(arr):
    n = len(arr)
    for i in range(n):
        for j in range(0, n-i-1):
            if arr[j] > arr[j+1]:
                arr[j], arr[j+1] = arr[j+1], arr[j]

def read_values_from_file(file_name):
    with open(file_name, 'r') as file:
        values = [int(line.strip()) for line in file]
    return values

def write_values_to_file(file_name, values):
    with open(file_name, 'w') as file:
        for value in values:
            file.write(str(value) + '\n')

def measure_sorting_time(values):
    start_time = time.time()
    bubble_sort(values)
    end_time = time.time()
    sorting_time = (end_time - start_time) * 1000 # в миллисекундах
    return sorting_time

file_names = ['m1_sorted.txt', 'm2_reverse.txt', 'm3_shuffle.txt']

for file_name in file_names:
    values = read_values_from_file(file_name)
    sorting_time = measure_sorting_time(values)
    print(f"Время сортировки для файла {file_name}: {sorting_time} мс")